package com.koocloud.electroplatemanage.controller;

import com.koocloud.electroplatemanage.common.pojo.ResponseTemplate;
import com.koocloud.electroplatemanage.pojo.IncomeBasicInfoVo;
import com.koocloud.electroplatemanage.service.OperationCardService;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: Information_platform
 * @description: 工艺卡片控制层
 * @author: xxc
 * @create: 2020-11-12 16:28
 */
@RestController
@RequestMapping("/operationcard")
public class OperationCardController {
    static Logger log = Logger.getLogger("operationcard");

    @Autowired
    OperationCardService operationCardService;

    /**
     *@Description: 通过工单号查询一条工艺卡片信息
     *@Param: [workOrderNumber]
     *@return: com.koocloud.electroplatemanage.common.pojo.ResponseTemplate
     *@Author: xxc
     *@date: 2020/11/13
     */
    @RequestMapping(value = "/selectByWorkOrderNumber", method = RequestMethod.POST, name = "通过工单号查询一条工艺卡片信息")
    public ResponseTemplate selectByWorkOrderNumber(String workOrderNumber) {
        //通过工单号查询来件基本信息
        return operationCardService.selectByWorkOrderNumber(workOrderNumber);
    }

    /**
     *@Description: 通过工单号查询一条来件基本信息
     *@Param: [workOrderNumber]
     *@return: com.koocloud.electroplatemanage.common.pojo.ResponseTemplate
     *@Author: xxc
     *@date: 2020/11/13
     */
    @RequestMapping(value = "/selectIncomeBasicInfo", method = RequestMethod.POST, name = "通过工单号查询一条来件基本信息")
    public ResponseTemplate selectIncomeBasicInfo(String workOrderNumber) {
        //通过工单号查询来件基本信息
        return operationCardService.selectIncomeBasicInfo(workOrderNumber);
    }

    /**
     *@Description: 对来件基础信息进行全表查询 分页
     *@Param: [page, limit, incomeBasicInfoVo] 页数 条数 来件基础信息实体类（模糊查询用）
     *@return: com.koocloud.electroplatemanage.common.pojo.ResponseTemplate
     *@Author: xxc
     *@date: 2020/11/13
     */
    @RequestMapping(value = "/selectAllIncomeBasicInfo", method = RequestMethod.POST, name = "对来件基础信息进行全表查询")
    public ResponseTemplate selectAllIncomeBasicInfo(String page, String limit, IncomeBasicInfoVo incomeBasicInfoVo) {
        //分页参数为空则赋值0
        if (!StringUtils.isNotEmpty(page)) {
            page = "0";
        }
        if (!StringUtils.isNotEmpty(limit)) {
            limit = "0";
        }
        //查询所有记录 分页
        return operationCardService.selectAllIncomeBasicInfo(page,limit,incomeBasicInfoVo);
    }

    /**
     *@Description: 新增一条来件基础信息数据
     *@Param: [incomeBasicInfoVo]
     *@return: com.koocloud.electroplatemanage.common.pojo.ResponseTemplate
     *@Author: xxc
     *@date: 2020/11/13
     */
    @RequestMapping(value = "/insertIncomeBasicInfo", method = RequestMethod.POST, name = "新增一条来件基础信息数据")
    public ResponseTemplate insertIncomeBasicInfo(@RequestBody IncomeBasicInfoVo incomeBasicInfoVo) {
        //插入一条记录
        return operationCardService.insertIncomeBasicInfo(incomeBasicInfoVo);
    }

    /**
     *@Description: 逻辑删除一条来件基础信息记录
     *@Param: [workOrderNumber, deleteFlag]
     *@return: com.koocloud.electroplatemanage.common.pojo.ResponseTemplate
     *@Author: xxc
     *@date: 2020/11/13
     */
    @RequestMapping(value = "/deleteIncomeBasicInfo", method = RequestMethod.POST, name = "逻辑删除一条来件基础信息记录")
    public ResponseTemplate deleteIncomeBasicInfo(@RequestParam(name="workOrderNumber") String workOrderNumber, @RequestParam(name="deleteFlag") String deleteFlag) {
        //逻辑删除一条记录
        return operationCardService.deleteIncomeBasicInfo(workOrderNumber,deleteFlag);
    }

    /**
     *@Description: 修改一条来件基础信息记录
     *@Param: [incomeBasicInfoVo]
     *@return: com.koocloud.electroplatemanage.common.pojo.ResponseTemplate
     *@Author: xxc
     *@date: 2020/11/13
     */
    @RequestMapping(value = "/updateIncomeBasicInfo", method = RequestMethod.POST, name = "修改一条来件基础信息记录")
    public ResponseTemplate updateIncomeBasicInfo(@RequestBody IncomeBasicInfoVo incomeBasicInfoVo) {
        //修改一条记录
        return operationCardService.updateIncomeBasicInfo(incomeBasicInfoVo);
    }


}
